<template>
  <div>
    <!-- 新鲜好物 -->
    <section>
      <div class="good">
        <div class="container">
          <div class="good-title">
            <div class="title-left">
              <h1>新鲜好物</h1>
              <span>新鲜出炉 品质靠谱</span>
            </div>
            <div class="title-right"><a href="">查看全部 ></a></div>
          </div>
          <div class="good-list">
            <ul>
              <li v-for="fresh in freshList" :key="fresh.id">
                <img :src="fresh.picture" alt="" />
                <div class="good-desc">
                  <span>{{fresh.name}}</span>
                  <p>￥{{fresh.price}}</p>
                </div>
              </li>
             
            </ul>
          </div>
        </div>
      </div>
    </section>
  </div>
</template>

<script>
import { mapState } from 'vuex';
export default {
    mounted(){
        this.$store.dispatch('getFreshList')
    },
computed:{
  ...mapState({
    freshList:(state)=>state.home.fresh
  })
}
};
</script>

<style>
.container{
    width: 1240px;
    margin: 0 auto;
}
.good {
  height: 521px;
}

.good-title {
  height: 115px;
  line-height: 115px;
}

.good-title .title-left {
  height: 115px;
  float: left;
}

.good-title .title-left h1 {
  display: inline;
  font-size: 30px;
  margin-right: 15px;
}

.good-title .title-left span {
  color: gray;
  font-size: 16px;
}

.good-title .title-right {
  float: right;
}

.good-title .title-right a {
  color: gray;
  font-size: 16px;
}

.good-title .title-right a:hover {
  color: #27ba9b;
}

.good-list {
  height: 406px;
}

.good-list ul {
  height: 406px;
  float: left;
}

.good-list ul li {
  top: 0;
  width: 306px;
  height: 406px;
  float: left;
  background-color: #f0f9f4;
  text-align: center;
}

.good-list ul li:not(:last-child) {
  margin-right: 5px;
}

.good-list ul li:hover {
  position: relative;
  top: -10px;
  transition: all 0.4s linear;
  box-shadow: 4px 5px 3px rgba(0, 0, 0, 0.2), -3px 0 3px rgba(0, 0, 0, 0.2);
  cursor: pointer;
}

.good-list ul li img {
  width: 306px;
  height: 306px;
}

.good-list ul li .good-desc {
  height: 100px;
  padding: 12px 30px 0;
}

.good-list ul li .good-desc span {
  display: inline-block;
  width: 260px;
  font-size: 23px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.good-list ul li .good-desc p {
  font-size: 21px;
  color: red;
  margin-top: 10px;
}

.good-list ul li .good-desc .renqi {
  color: gray;
}
</style>